<template>
  <div class="photoinfo-container">
    <!--{{ $route.params.id}}-->
    <p class="photo-title">{{photoInfo.title}}</p>
    <p class="sub-title">
      <span>时间：{{photoInfo.addTime|dateFormat('YYYY-MM-DD')}}</span>
      <span>点击：{{photoInfo.click}}次</span>
    </p>
    <hr>
    <!--缩略图片-->
    <vue-preview :slides="slide1" @close="handleClose"></vue-preview>

    <div class="content" v-html="photoInfo.content"></div>
    <!--评论子组件-->
    <comment-box :id="this.id"></comment-box>
  </div>
</template>

<script>
//1.导入 评论子组件
import comment from "../subcomponents/comment.vue";
import { Toast } from "mint-ui";
export default {
  data() {
    return {
      id: this.$route.params.id,
      photoInfo: {},
      //缩略图数据
      slide1: [
        {
          src:
            "https://farm6.staticflickr.com/5591/15008867125_68a8ed88cc_b.jpg",
          msrc:
            "https://farm6.staticflickr.com/5591/15008867125_68a8ed88cc_m.jpg",
          alt: "picture1",
          title: "Image Caption 1",
          w: 600,
          h: 400
        },
        {
          src:
            "https://farm4.staticflickr.com/3902/14985871946_86abb8c56f_b.jpg",
          msrc:
            "https://farm4.staticflickr.com/3902/14985871946_86abb8c56f_m.jpg",
          alt: "picture2",
          title: "Image Caption 2",
          w: 1200,
          h: 900
        }
      ]
    };
  },
  created() {
    this.getphotoInfo();
  },
  methods: {
    getphotoInfo() {
      this.$http.get("photoInfo#!method=get").then(result => {
        if (result.status === 200) {
          this.photoInfo = result.body.message[0];
        } else {
          Toast("图片详情获取失败");
        }
      });
    },
    handleClose () {
        console.log('close event')
      }
  },
  components: {
    "comment-box": comment
  }
};
</script>

<!--为了让内容里的图片能够是100%  要把 scoped 去了-->
<style lang="scss">
.photoinfo-container {
  padding: 10px 5px 0;
  .photo-title {
    font-size: 14px;
    line-height: 30px;
    color: #333;
    text-align: center;
    margin: 0 auto;
  }
  .sub-title {
    font-size: 12px;
    line-height: 24px;
    color: #ddd;
    margin: 0 auto;
  }
  .content {
    font-size: 12px;
    line-height: 24px;
    img {
      max-width: 100%;
    }
  }
}
</style>